package com.workcell.workdata.im.repository;


import com.workcell.workdata.im.entity.Chat;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
@Transactional(rollbackFor = Exception.class)
public interface ChatRepository extends JpaRepository<Chat, Long> {



    @Query("from Chat where action = ?1 and uid = ?2 and chatId = ?3 ")
    Chat findByType(String action,Long  uid,Long chatId);



    @Query("from Chat where uid = ?1 and state= " + 0)
    List<Chat> findListByUid(long uid);


    @Query("from Chat where   id = ?1")
    Chat findChatById(Long id);
}
